{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# Using the planner\n",
    "\n",
    "In this notebook, we will demonstrate how to use the planner to generate plans by providing a prompt to the model.\n",
    "\n",
    "Firstly, we will load the model and the planner. The system prompt show what environment the model is in. If you have relevant tools to use, you need to tell the Planner so that it can generate the appropriate plan."
   ],
   "id": "c7816123f07380d"
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-05-12T20:55:27.148698Z",
     "start_time": "2024-05-12T20:55:24.214596Z"
    }
   },
   "source": [
    "import promptulate as pne\n",
    "\n",
    "model = pne.LLMFactory.build(\"gpt-4-turbo\")\n",
    "planner = pne.Planner(model, system_prompt=\"You are a planner\")"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-12T20:55:49.892144Z",
     "start_time": "2024-05-12T20:55:38.361456Z"
    }
   },
   "cell_type": "code",
   "source": "plans = planner.run(\"Plan a trip to Paris\")",
   "id": "3b288fee5567be4d",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-05-12T20:55:49.907847Z",
     "start_time": "2024-05-12T20:55:49.893212Z"
    }
   },
   "cell_type": "code",
   "source": "print(plans)",
   "id": "7436643c60a221bf",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('goals', ['Plan a trip to Paris'])\n",
      "('tasks', [Task(task_id=1, description='Check passport validity', status=<TaskStatus.TODO: 'todo'>), Task(task_id=2, description='Determine travel dates', status=<TaskStatus.TODO: 'todo'>), Task(task_id=3, description='Research and book flights', status=<TaskStatus.TODO: 'todo'>), Task(task_id=4, description='Book accommodations', status=<TaskStatus.TODO: 'todo'>), Task(task_id=5, description='Plan itinerary for the trip', status=<TaskStatus.TODO: 'todo'>), Task(task_id=6, description='Investigate and purchase travel insurance', status=<TaskStatus.TODO: 'todo'>), Task(task_id=7, description='Set a budget for the trip', status=<TaskStatus.TODO: 'todo'>), Task(task_id=8, description='Pack luggage', status=<TaskStatus.TODO: 'todo'>), Task(task_id=9, description='Notify bank of international travel', status=<TaskStatus.TODO: 'todo'>), Task(task_id=10, description='Check weather forecast and pack accordingly', status=<TaskStatus.TODO: 'todo'>)])\n",
      "('next_task_id', 1)\n"
     ]
    }
   ],
   "execution_count": 4
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
